package cn.ztelovecly.springboot.bussiness.biz;

import cn.ztelovecly.springboot.bussiness.dal.UserMapper;
import cn.ztelovecly.springboot.bussiness.po.UserPO;
import cn.ztelovecly.springboot.contract.request.UserCreateRequest;
import cn.ztelovecly.springboot.contract.response.UserCreateResponse;
import cn.ztelovecly.springboot.framework.base.BaseManagerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
/**
 * Created by zhaotianen on 2017/2/18.
 */
@Transactional
@Service("UserManager")
public class UserManagerImpl extends BaseManagerImpl implements UserManager {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserCreateResponse create(UserCreateRequest request) {
        UserCreateResponse response=new UserCreateResponse();
        UserPO userPO=JSON.parseObject(JSON.toJSONString(request), UserPO.class);
        Long result=userMapper.insert(userPO);
        response.setId(result);
        return response;
    }
}
